﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NodeBasedSkillEditor
{
    public abstract class PortCluster
    {
    }

    public class PortClusterGroup
    {
        /// <summary>
        /// LocalId只对编辑器有意义，用于帮助操作历史在恢复一个PortCluster时，定位到正确的PortClusterGroup，其在运行时是没有用的
        /// 这个LocalId和所属Node下其他Port采用的LocalId在同一个id空间中
        /// </summary>
        public uint LocalId;
        public List<PortCluster> Clusters = new List<PortCluster>(4);

        public PortCluster TypeHolder;
        public Type GetClusterType() { return TypeHolder.GetType(); }

        public PortClusterGroup(Type clusterType)
        {
            TypeHolder = Activator.CreateInstance(clusterType) as PortCluster;
        }

        public PortClusterGroup() { }

        public PortCluster CreateNewCluster()
        {
            var newCluster = Activator.CreateInstance(TypeHolder.GetType()) as PortCluster;
            Clusters.Add(newCluster);
            return newCluster;
        }

        public bool RemoveCluster(PortCluster cluster)
        {
            return Clusters.Remove(cluster);
        }
    }
}
